// 题目链接: https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters/
class Solution 
{
public:
    string modifyString(string s) 
    {
        int n = s.size();

        for (int i = 0; i < n; i++)
        {
            if (s[i] == '?') // 遇到了? 替换
            {
                // 找到一个不存在连续重复的字符
                for (char ch = 'a'; ch <= 'z'; ch++)
                {
                    // 判断当前字符是否和前后字符相同
                    if ((i == 0 || ch != s[i - 1]) && (i == n - 1 || ch != s[i + 1]))
                    {
                        s[i] = ch; // 替换
                        break;
                    }
                }
            }
        }
        return s;
    }
};